import axios from 'common/js/token/request'

export function MyOrder(OrderStatus,PageNumber) {
  let  api = '' ;
  if(OrderStatus ==='Processing'){
    api = '/processingOrders'
  }else if(OrderStatus ==='Confirm'){
    api ='/confirmedOrders'
  }else if(OrderStatus === 'Unable'){
    api ='/unableToConfirmOrders'
  }else if(OrderStatus ==='Transfered'){
    api ='/transferredOrders'
  }else if(OrderStatus === 'All'){
    api =''
  }
    return axios.get('/api/Orders/cashback'+api, {
      params: {
        PageNumber:PageNumber,
        PageSize: 10,
      }
    }).then((response) => {
      return Promise.resolve(response.data)
    })
      .catch(function (error) {
        console.log(error)
        return Promise.reject(error)
      })
  }
//promotion订单
export function MyOrderPromotion(PageNumber) {
  return axios.get('/api/Orders/promotion', {
    params: {
      PageNumber:PageNumber,
      PageSize: 20,
    }
  }).then((response) => {
    return Promise.resolve(response.data)

  })
    .catch(function (error) {
      console.log(error)
    })
}
export function customerPaid(orderNo,params) {
  return axios.post(`api/orders/promotion/${orderNo}/customerPaid`, params).then((response) => {
    return Promise.resolve(response.data)

  })
}
//删除 promotion 订单
export function MyOrderCancel(orderNo) {
  return axios.post('/api/Orders/'+ orderNo +'/cancel', {

  }).then((response) => {
    return Promise.resolve(response.data)

  })
    .catch(function (error) {
      console.log(error)
    })
}

